package cn.lhjl.day09.reflect;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

public class Test {
    public static void main(String[] args) {
        Class personClass = Person.class;
        Method[] methods = personClass.getMethods();
        try {
            Method getName_method = personClass.getMethod("getName");
            System.out.println(getName_method.invoke(new Person()));

        } catch (NoSuchMethodException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (InvocationTargetException e) {
            e.printStackTrace();
        }
    }
}
